package day19;

import java.io.*;

/**
 * @author ZJX
 * @version 1.0
 * @descption
 * @since 2025/10/29 20:24
 */
public class Day16 {
    public String formatString(String str, char[] arg) {
        StringBuilder sb = new StringBuilder(str);
        int j = 0;
        for (int i = 1; i < sb.length(); i++) {
            if (sb.charAt(i - 1) == '%' && sb.charAt(i) == 's') {
                sb.delete(i - 1, i + 1); // 删除区间 前闭后开
                sb.insert(i - 1, arg[j++]);
            }
        }
        for (int i = j; i < arg.length; i++) {
            sb.append(arg[i]);
        }
        return sb.toString();
    }


//    public static void main(String[] args) throws IOException {
//        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        PrintWriter out = new PrintWriter(System.out);
//        in.nextToken();
//        int a = (int) in.nval;
//        in.nextToken();
//        int b = (int) in.nval;
//        int count = 0;
//
//        for (int num = a; num <= b; num++) {
//            List<Integer> digits = new ArrayList<>();
//            int temp = num;
//            // 提取所有数位
//            while (temp > 0) {
//                digits.add(temp % 10);
//                temp = temp / 10;
//            }
//            boolean isMagic = false;
//            int len = digits.size();
//            // 遍历所有数位对 (i, j)，i≠j
//            for (int i = 0; i < len; i++) {
//                for (int j = 0; j < len; j++) {
//                    if (i == j) continue;
//                    int ten = digits.get(i);
//                    int one = digits.get(j);
//                    if (ten == 0) continue; // 前导0无效
//                    int twoDigit = ten * 10 + one;
//                    if (isPrime(twoDigit)) {
//                        isMagic = true;
//                        break;
//                    }
//                }
//                if (isMagic) break;
//            }
//            if (isMagic) {
//                count++;
//            }
//        }
//
//        out.println(count);
//        out.close();
//    }

    // 判断一个数是否为质数
    private static boolean isPrime(int n) {
        if (n < 2) return false;

        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) return false;
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken();
        String s = in.sval;
        in.nextToken();
        int n = (int) in.nval; // 窗口大小
        int left = 0;
        int maxLeft = 0;
        int curType = 0;
        int maxType = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'C' || s.charAt(i) == 'G') {
                curType++;
            }
        }
        maxType = curType;
        for (int i = n; i < s.length(); i++) {
            char leftChar = s.charAt(left);
            if (leftChar == 'C' || leftChar == 'G') {
                curType--;
            }
            left++;
            char rightChar = s.charAt(i);
            if (rightChar == 'C' || rightChar == 'G') {
                curType++;
            }
            if (curType > maxType) {
                maxType = curType;
                maxLeft = left;
            }
        }

        out.println(s.substring(maxLeft, maxLeft + n));
        out.close();
    }
}

